/*
** trantorian.c for  in /home/tessa_b//proj/zappy-2011/smap/trantor/trantorian
** 
** Made by arnaud1 tessa
** Login   <tessa_b@epitech.net>
** 
** Started on  Thu Jul  7 09:19:17 2011 arnaud1 tessa
** Last update Thu Jul  7 09:56:18 2011 arnaud1 tessa
*/

#include	<string.h>
#include	<time.h>
#include	<stdlib.h>
#include	<stdio.h>
#include	"trantorian.h"

int		trantorian_init(t_trantorian *tr, int x, int y, char *team_name)
{
  struct timeval tv;
  
  gettimeofday(&tv, NULL);
  srand(tv.tv_usec);
  tr->x = rand() % x;
  tr->y = rand() % y;
  tr->direction = rand() % 4;
  tr->level = 0;
  tr->inventaire.nourriture = 10;
  tr->inventaire.linemate = 0;
  tr->inventaire.deraumere = 0;
  tr->inventaire.sibur = 0;
  tr->inventaire.mendiane = 0;
  tr->inventaire.phiras = 0;
  tr->inventaire.thystame = 0;
  tr->team_name = strdup(team_name);
  if (tr->team_name == NULL)
    {
      printf("trantorian_init : out of memory\n");
      return (0);
    }
  return (1);
}

void		trantorian_delete(t_trantorian *tr)
{
  free(tr->team_name);
}

/*
void		trantorian_avance(t_trantorian *tr);
void		trantorian_droite(t_trantorian *tr);
void		trantorian_gauche(t_trantorian *tr);
char		*trantorian_voir(t_trantorian *tr);
char		*trantorian_inventaire(t_trantorian *tr);
int		trantorian_prend(t_trantorian *tr, char *r_name);
int		trantorian_pose(t_trantorian *tr, char *r_name);
int		trantorian_expulse(t_trantorian *tr);
void		trantorian_broadcast(t_trantorian *tr);
char		*trantorian_incantation(t_trantorian *tr);
void		trantorian_fork(t_trantorian *tr);
char		*trantorian_connect_nbr(t_trantorian *tr);
*/

void		trantorian_display(t_trantorian *tr)
{
  printf("x = %d\ny = %d\n", tr->x, tr->y);
  if (tr->direction == NORTH)
    printf("direction : nord\n");
  else if (tr->direction == SOUTH)
    printf("direction : sud\n");
  else if (tr->direction == EAST)
    printf("direction : est\n");
  else
    printf("direction : ouest\n");
  printf("level = %d\n", tr->level);
  printf("inventaire : %s\n", resources_to_string(&(tr->inventaire)));
  printf("team : %s\n", tr->team_name);
}

/*
int		main()
{
  t_trantorian	t;

  trantorian_init(&t, 42, 42, "test");
  trantorian_display(&t);
  trantorian_delete(&t);
  return (0);
}
*/
